using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;

using Home.Controls;

namespace Home.Web
{
    public class Employee
    {
        public Employee(string fname, string lname)
        {
            m_firstname = fname;
            m_lastname = lname;
        }

        private string m_firstname;

        public string FirstName
        {
            get { return m_firstname; }
            set { m_firstname = value; }
        }
        private string m_lastname;

        public string LastName
        {
            get { return m_lastname; }
            set { m_lastname = value; }
        }
    }

    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            ShowTree();
            

        }
        protected void ShowTree()
        {
            Employee e1 = new Employee("Nancy", "Davalio");
            Employee e2 = new Employee("Andrew", "Fuller");
            Employee e3 = new Employee("Huang", "Hurry");
            Employee e4 = new Employee("Jin", "Faster");
            Employee e5 = new Employee("aa", "dd");
            Employee e6 = new Employee("bb", "aa");
            Employee e7 = new Employee("cc", "ff");

            TreeListNode root = new TreeListNode();
            root.Text = "root";
            root.Expanded = true;
            root.ToolTip = "root ToolTip";
            root.ImageToolTip = "ImageToolTip";
            root.DataSource = e1;
            //root.Data.Add("FirstName",e1.FirstName);
            root.SetNodeValue("LastName", e1.LastName);
            root.ImageUrl = "knowledge.gif";

            TreeListNode node = new TreeListNode();
            node.Text = "node1";
            node.DataSource = e2;
            node.SetNodeValue("FirstName", e2.FirstName);
            node.SetNodeValue("FirstName", e2.FirstName + "aaa");
            //node.Data.Add("LastName",e2.LastName);
            node.ImageUrl = "knowledge.gif";

            TreeListNode node12 = new TreeListNode();
            node12.Text = "node12";
            node12.Expanded = true;
            node12.DataSource = e3;
            node12.SetNodeValue("FirstName", e3.FirstName);
            node12.SetNodeValue("LastName", e3.LastName);
            node12.ImageUrl = "knowledge.gif";

            TreeListNode node13 = new TreeListNode();
            node13.Text = "node13";
            node13.DataSource = e5;
            node13.SetNodeValue("FirstName", e5.FirstName);
            node13.SetNodeValue("LastName", e5.LastName);
            node13.ImageUrl = "knowledge.gif";

            TreeListNode node2 = new TreeListNode();
            node2.Text = "node2";
            node2.DataSource = e4;
            node2.SetNodeValue("FirstName", e4.FirstName);
            node2.SetNodeValue("LastName", e4.LastName);
            node2.ImageUrl = "knowledge.gif";

            TreeListNode node121 = new TreeListNode();
            node121.Text = "node121";
            node121.DataSource = e6;
            node121.SetNodeValue("FirstName", e6.FirstName);
            node121.SetNodeValue("LastName", e6.LastName);
            node121.ImageUrl = "knowledge.gif";

            TreeListNode node1211= new TreeListNode();
            node1211.Text = "node1211";
            node1211.DataSource = e7;
            //node1211.Data.Add("FirstName",e6.FirstName);
            //node1211.Data.Add("LastName",e6.LastName);
            node1211.ImageUrl = "knowledge.gif";

            node.ChildNodes.Add(node12);
            root.ChildNodes.Add(node);
            root.ChildNodes.Add(node2);

            node.ChildNodes.Add(node13);
            node12.ChildNodes.Add(node121);
            node121.ChildNodes.Add(node1211);

            this.TreeListView1.IsShowRootNode = true;
            this.TreeListView1.ExpandDepth = 5;
            this.TreeListView1.Root = root;
            this.TreeListView1.DataBind();

        }

        protected string GetBgColor(int id)
        {
            if (id==0 || id%2==0)
            {
                return @"#ffffff";
            }
            else
            {
                return @"#EEEEEE";
            }
        }
    }
}